package mrpanyu.guitool.base.util;

import mrpanyu.guitool.base.model.Tool;

public final class Log {

	private static Tool tool;

	public static void setTool(Tool t) {
		tool = t;
	}

	public static boolean isDebugEnabled() {
		if (tool == null) {
			return false;
		} else {
			return tool.isDebugEnabled();
		}
	}

	public static void debug(String message) {
		if (tool == null) {
			System.out.println(message);
		} else {
			tool.debugMessage(message);
		}
	}

	public static void info(String message) {
		if (tool == null) {
			System.out.println(message);
		} else {
			tool.infoMessage(message);
		}
	}

	public static void warn(String message) {
		if (tool == null) {
			System.out.println(message);
		} else {
			tool.warnMessage(message);
		}
	}

	public static void error(String message) {
		if (tool == null) {
			System.err.println(message);
		} else {
			tool.errorMessage(message);
		}
	}

	public static void error(Throwable t) {
		if (tool == null) {
			t.printStackTrace();
		} else {
			tool.errorMessage(t);
		}
	}

	public static void error(String message, Throwable t) {
		if (tool == null) {
			System.err.println(message);
			t.printStackTrace();
		} else {
			tool.errorMessage(message);
			tool.errorMessage(t);
		}
	}

	private Log() {
	}

}
